package com.ymatou.iapi.wxtoken.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.wxtoken.parameter.EnableWxConfigBean;
import com.ymatou.iapi.wxtoken.service.EnableWxConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.mapping.wxconfigMapper;
import com.ymttest.database.model.wxconfig;
import com.ymttest.database.sqlwapper.WXToken2Wapper;
import com.ymttest.database.sqlwapper.WxConfigWapper;
/**
*开启微信token配置Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_EnableWxConfig{
	private static EnableWxConfigBean enablewxconfigBean;
	private static EnableWxConfigCall enablewxconfigCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("开启微信token配置Test");
	}

	@Before
	public void caseUp() {
		enablewxconfigBean=new EnableWxConfigBean();
		enablewxconfigCall=new EnableWxConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(enablewxconfigCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_EnableWxConfig_001() {
		Logger.start(true,"正确数据，成功");
		try {
			//数据库action修改为-1
			wxconfig wxc = new WxConfigWapper().SelectWxConfig(1185);
			wxc.setAction(-1);
			new WxConfigWapper().UpdateWxConfig(wxc);
			
			// 取消授权-回调mq ---
			enablewxconfigBean.setMchid(wxc.getUserId());
			enablewxconfigCall.setData(enablewxconfigBean);
			enablewxconfigCall.callService();
			Logger.verifyEquals("ok", enablewxconfigCall.getReturnData(), "验证返回");
			
			wxconfig wxc1 = new WxConfigWapper().SelectWxConfig(wxc.getId());
			Logger.verifyEquals(wxc1.getAction(), 0, "action回复正常");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}